package com.sky.service.impl;

import com.sky.context.BaseContext;
import com.sky.entity.AddressBook;
import com.sky.mapper.AddressBookMapper;
import com.sky.service.AddressBookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AddressBookServiceImpl implements AddressBookService {
    @Autowired
    AddressBookMapper addressBookMapper;
    @Override
    public void add(AddressBook addressBook) {
        addressBookMapper.add(addressBook);
    }

    @Override
    public List<AddressBook> list() {
        Long userId= BaseContext.getCurrentId();
        return addressBookMapper.list(userId);
    }

    @Override
    public AddressBook getDefault() {
        Long id=BaseContext.getCurrentId();
        return addressBookMapper.getDefault(id);
    }

    @Override
    public void update(AddressBook addressBook) {

        addressBookMapper.update(addressBook);
    }

    @Override
    public void delete(Long id) {

        addressBookMapper.delete(id);
    }

    @Override
    public AddressBook get(Long id) {
        return addressBookMapper.get(id);
    }

    @Override
    public void setDefault(Integer id) {
        addressBookMapper.setdefault(id);
    }
}
